package czh.cocoa.foundation;

import java.util.ArrayList;

public class NSMutableArray extends NSArray {
	
	public static NSArray arrayWithObjects(NSObject... objects) {
		return new NSMutableArray(NSArray.arrayWithObjects(objects)); 
	}
	
	public NSMutableArray() {  
		
	}
	
	public NSMutableArray(NSArray array) {
		super(array);
	}
	
	public NSMutableArray(int capacity) {
		super(capacity);
	}

	public void addObject(NSObject obj) {
		mArray.add(obj);
	}
	
	public void addObjectsFromArray(NSArray array) {
		mArray.addAll(array.mArray);
	}
	
	public void insertObjectAtIndex(NSObject obj, int index) {
		mArray.add(index, obj); 
	}
	
	public void removeObject(NSObject obj) {
		mArray.remove(obj);
	}
	
	public void removeObjectAtIndex(int index) {
		mArray.remove(index);
	}
	
	public void removeAllObjects() {
		mArray.clear();
	}
	
	public void removeLastObject() {
		removeObjectAtIndex(count() - 1); 
	}
	
	public void replaceObjectAtIndexWithObject(int index, NSObject obj) {
		mArray.remove(index);
		mArray.add(index, obj);
	}
	
	public void removeObjectsInRange(NSRange range) {
		for (int i = 0; i < range.length; i++) {
			mArray.remove(range.location);
		}
	}
	
}




